//
//  MenkSlider.m
//  OMG
//
//  Created by Burn on 2019/7/9.
//  Copyright © 2019 menksoft. All rights reserved.
//

#import "MenkSlider.h"

@implementation MenkSlider

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    //  获取轨道的Frame
    CGRect t = [self trackRectForBounds: [self bounds]];
    // 获取x轴上的长度 * 比例 // max - min / 轨道的宽度 = value
    float v = [self minimumValue] + ([[touches anyObject] locationInView: self].x - t.origin.x - 4.0) * (([self maximumValue]-[self minimumValue]) / (t.size.width - 8.0));
    [self setValue: v];
    self.changeValue(v);
    [super touchesBegan: touches withEvent: event];
}

@end
